
<%--
    Document   : oEstrategico
    Created on : 10/04/2010, 03:05:56 PM
    Author     : LAPTOP01
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://struts.apache.org/tags-bean"  prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="/tags/c" prefix="c"%>
<%@ include file="seguridad.jsp" %>
<%@ include file="acceso.jsp" %>



<html>
    <script LANGUAGE="JavaScript">
        
        /*function cambiarPPTO(){
            var id = document.getElementById("codMetaAPer").value;
            var ppto=document.getElementById("presuActPer").value;
            var proc=1;
            var idDiv = "divTabla";
            var metodo = "GET";
            var url = "consultasAjax/listarActMetAjax.jsp?id="+id+"&ppto="+ppto+"&proc="+proc;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);

        }*/
        function comboOEspecifico(){
            describirog();
            var id = document.getElementById("codObj").value;
            var idDiv = "comboOESpecifico";
            var metodo = "GET";
            var url = "consultasAjax/comboOEspecificoAjax.jsp?id="+id;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
        }


        function NuevaAPermanente(){
           
            descActividad();
           
            if(document.getElementById("codActPer").value==0){
                document.getElementById("nuevaactividad").style.display="";
                document.getElementById("btneditar").style.display="none";
                document.getElementById("detalle").style.display="none";
                document.getElementById("divTabla").style.display="none";
                document.getElementById("btnbuscar").style.display="none";
            }
        }


        function comboAPermanente(){
          describiroe();
            var id = document.getElementById("codObjEsp").value;
            var idDiv = "comboAPermanente";
            var metodo = "GET";
            var url = "consultasAjax/comboAPermanenteModAjax.jsp?id="+id;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
        }
        
        function comboAPermanenteid(id){
            var idDiv = "comboAPermanente";
            var metodo = "GET";
            var url = "consultasAjax/comboAPermanenteModAjax.jsp?id="+id;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
        }




        function descActividad(){
            var codActPer = document.getElementById("codActPer").selectedIndex;
            var descActPer = document.PEIForm.codActPer.options[codActPer].text;
            document.getElementById("descActPer").value=descActPer;
        }


        function describirog(){
            var idObj = document.getElementById("codObj").selectedIndex;
            var descObj = document.PEIForm.codObj.options[idObj].text;
            document.getElementById("descObj").value=descObj;
        }

        function describiroe(){
            var idObje = document.getElementById("codObjEsp").selectedIndex;
            var descObje = document.PEIForm.codObjEsp.options[idObje].text;
            document.getElementById("descObjEsp").value=descObje;
        }

        function  buscar(){
            document.getElementById("divTabla").style.display="";
            document.getElementById("nuevaactividad").style.display="none";
            var id = document.getElementById("codActPer").value;
            var idDiv = "divTabla";
            var metodo = "GET";
            var url = "consultasAjax/listarActMetMAjax.jsp?id="+id;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv); 
        }



        function editarT(codactp,codmactp,presumactp,ummactp,cantmactp,tipmactp){
            tipmactp=tipmactp.replace(/^\s*|\s*$/g,"");
            if(tipmactp=="N"){
                document.getElementById("tipoActPer").value=1;
            }
            else{
                document.getElementById("tipoActPer").value=2;
            }
            document.getElementById("detalle").style.display="";
            document.getElementById("btneditar").style.display="";
            document.getElementById("btnbuscar").style.display="none";
            document.getElementById("opcionObj").value=1;
            document.getElementById("codActPerM").value=codactp;
            document.getElementById("codMetaAPerM").value=codmactp;
            document.getElementById("presupActPer").value=presumactp;
            document.getElementById("umActPer").value=ummactp;
            document.getElementById("cantActPer").value=cantmactp;
        }

        /*function eliminar(codigo){
            var desc = document.getElementById("descObj").value;
            var idDiv = "divTabla";
            var metodo = "GET";
            var tipo = 3;
            var url = "consultasAjax/listarObjetivosAjax.jsp?desc="+desc+"&codigo="+codigo+"&tipo="+tipo;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
        }*/


        function grabar(){
            document.getElementById("btneditar").style.display="none";
            document.getElementById("detalle").style.display="none";
            document.getElementById("btnbuscar").style.display="";
            var id = document.getElementById("codActPerM").value;
            var id2 = document.getElementById("codMetaAPerM").value;
            var presap = document.getElementById("presupActPer").value;
            var umap = document.getElementById("umActPer").value;
            var cantap = document.getElementById("cantActPer").value;
            var tipap = document.getElementById("tipoActPer").value;
            var tipo = document.getElementById("opcionObj").value;
            if(tipap==1){
                tipap="N"
            }
            if(tipap==2){
                tipap="%25"
            }
            var idDiv = "divTabla";
            var metodo = "GET";
            var url = "consultasAjax/listarActMetMoAjax.jsp?id="+id+"&id2="+id2+"&presap="+presap
                +"&umap="+umap+"&cantap="+cantap+"&tipap="+tipap+"&tipo="+tipo;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            document.getElementById("presupActPer").value=0;
            document.getElementById("umActPer").value="";
            document.getElementById("cantActPer").value=0;
            document.getElementById("tipoActPer").value=-1;
        }


        function grabarnuevo(){
            document.getElementById("nuevaactividad").style.display="none";
            document.getElementById("btnbuscar").style.display="";
            var codObjEsp = document.getElementById("codObjEsp").value;
            var id = document.getElementById("codActPermMod").value;
            var id2 = document.getElementById("codMActPermMod").value;
            var descactp = document.getElementById("descActPermMod").value;
            var umap = document.getElementById("umActPermMod").value;
            var cantap = document.getElementById("cantActPermMod").value;
            var tipap = document.getElementById("tipoActPerMod").value;
            var tipo = document.getElementById("opcActPermMod").value;
            if(tipap==1){
                tipap="N"
            }
            if(tipap==2){
                tipap="%25"
            }
            var idDiv = "comboAPermanente";
            var metodo = "GET";
            var url = "consultasAjax/listarActMetModAjax.jsp?id="+id+"&id2="+id2+"&descactp="+descactp
                +"&umap="+umap+"&cantap="+cantap+"&tipap="+tipap+"&tipo="+tipo+"&codObjEsp="+codObjEsp;
            var cadenaSalida = "";
            var async = true;
            document.getElementById(idDiv).innerHTML;
            autoCompletarDiv(metodo,url,cadenaSalida,async,idDiv);
            //alert("codObjEsp"+codObjEsp);
            //comboAPermanenteid(codObjEsp);
            document.getElementById("descActPermMod").value="";
            document.getElementById("umActPermMod").value="";
            document.getElementById("cantActPermMod").value=0;
            document.getElementById("tipoActPerMod").value=-1;
           
            //por implementar


        }

        function autoCompletarDiv(metodo,url,cadena,async,idDiv)
        {
            if( window.XMLHttpRequest )
                ajax = new XMLHttpRequest(); // No Internet Explorer
            else
                ajax = new ActiveXObject("Microsoft.XMLHTTP");
            ELEMENT_DIV = idDiv;
            ajax.onreadystatechange = funcionCallbackVerDiv;
            ajax.open( metodo, url, async);
            ajax.send(cadena);
        }

        function funcionCallbackVerDiv()
        {
            if( ajax.readyState == 4 )
            {
                if( ajax.status == 200 )
                { //alert(ajax.responseText);
                    document.getElementById(ELEMENT_DIV).innerHTML = ajax.responseText;
                }
            }
        }


        function iniciar(){
            document.getElementById("btneditar").style.display="none";
            document.getElementById("detalle").style.display="none";
            document.getElementById("nuevaactividad").style.display="none";
        }


       

        function cancelar(){
            document.getElementById("nuevaactividad").style.display="none";
            document.getElementById("btnbuscar").style.display="";
            document.getElementById("descActPermMod").value="";
            document.getElementById("umActPermMod").value="";
            document.getElementById("cantActPermMod").value=0;
            document.getElementById("tipoActPerMod").value=-1;
        }

        function isDecimalKey(evt) {
        if (!(evt.keyCode == 46 || (evt.keyCode >= 48 && evt.keyCode <= 57))) return false;
        var parts = evt.srcElement.value.split('.');
        if (parts.length > 2) return false;
        if (evt.keyCode == 46) return (parts.length == 1);
        if (parts[0].length >= 11) return false;
        if (parts.length == 2 && parts[1].length >= 2) return false;
    }

    function posicioninicial(){
            document.getElementById("umActPer").focus();
        }








    </script>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link type="text/css" rel="stylesheet" href="lib/css/Style_Index.css" >
        <link type="text/css" rel="stylesheet" href="lib/css/Style_Font_Text.css" >
        <link type="text/css" rel="stylesheet" href="lib/css/Style_PageTable.css" >

        <title>JSP Page</title>
    </head>
    <body onload="iniciar()">
        <center>
            <h1 class="substylo">Programaci&oacute;n Presupuestal</h1>
        </center>
        <div style="overflow: auto; width:710px; height: 400px">
        <html:form action="PEI.do?dispatch=ingresarOEstrategico" styleId="PEIForm"  >
            <html:hidden property="opcionObj" styleId="opcionObj" value="1"/>
            <html:hidden property="codActPerM" styleId="codActPerM"/>
            <html:hidden property="opcActPermMod" styleId="opcActPermMod" value="2"/>
            <html:hidden property="codMetaAPerM" styleId="codMetaAPerM"/>
            <html:hidden property="codActPermMod" styleId="codActPermMod"/>
            <html:hidden property="codMActPermMod" styleId="codMActPermMod"/>
            <table border="0" align="center" cellspacing="0" style="width: 600px">
                <tr>
                    <td style="width: 150px">Objetivo General Estrat&eacute;gico : </td>
                    <td style="width: 400px">
                        <html:select property='codObj' styleId='codObj' onchange='comboOEspecifico()' styleClass="select" style="width: 400px">
                            <html:option value='-1'>[--Seleccionar Objetivo General Estrat&eacute;gico--]</html:option>
                            <html:optionsCollection name='PEIForm' property='listaOEstrategico' value='NUM_CODOBJ_PK' label='TX_DESCOBJ' />
                        </html:select>
                    </td>

                </tr>
                <tr>
                    <td style="width: 150px"></td>
                    <td style="width: 400px">
                        <html:textarea  styleId="descObj" property="descObj"  rows="10" cols="50" disabled="true" />
                    </td>
                </tr>
                <tr>
                    <td style="width: 150px">Objetivo Espec&iacute;fico Estrat&eacute;gico: </td>
                    <td style="width: 400px">
                        <div id="comboOESpecifico">
                            <html:select property="codObjEsp" styleId="codObjEsp" style="width: 400px" styleClass="select">
                                <html:option value="-1">[--Seleccionar Objetivo Espec&iacute;fico Estrat&eacute;gico--]</html:option>
                                <html:optionsCollection name="PEIForm" property="listaOEspecifico" value="NUM_CODOBJESP_PK" label="TX_DESCOBJESP" />
                            </html:select>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td style="width: 150px"></td>
                    <td style="width: 400px">
                        <html:textarea  styleId="descObjEsp" property="descObjEsp"  rows="10" cols="50" disabled="true" />
                    </td>
                </tr>

                <tr>
                    <td style="width: 150px">Actividad Estrat&eacute;gica: </td>
                    <td style="width: 400px">
                        <div id="comboAPermanente">
                            <html:select property="codActPer" styleId="codActPer" styleClass="select" style="width: 400px">
                                <html:option value="-1">[--Seleccionar Actividad Estrat&eacute;gica--]</html:option>
                                <html:optionsCollection name="PEIForm" property="listaActPer" value="NUM_CODACTPER_PK" label="TX_DESCACTPER" />
                                <html:option value="0">Nueva Actividad Estrat&eacute;gica</html:option>
                            </html:select>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td style="width: 150px"></td>
                    <td style="width: 400px">
                        <html:textarea  styleId="descActPer" property="descActPer"  rows="10" cols="50" disabled="true" />
                    </td>
                </tr>

                <tr id="btnbuscar">
                    <td colspan="2" align="center"><input type="button" value="Buscar" onclick="buscar()" class="submit2"/></td>
                </tr>
            </table>
            <br>
            <table border="1" align="center" cellspacing="0" id="nuevaactividad">
                <tr>
                    <td>Actividad Estrat&eacute;gica</td>
                    <td>
                        <html:text property="descActPermMod"  styleId="descActPermMod"/>
                    </td>
                </tr>
                <tr>
                    <td>Descripci&oacute;n de Meta</td>
                    <td>
                        <html:text property="umActPermMod"  styleId="umActPermMod"/>
                    </td>
                </tr>
                <tr>
                    <td>Cantidad</td>
                    <td>
                        <html:text property="cantActPermMod"   styleId="cantActPermMod"/>
                    </td>
                </tr>
                <tr>
                    <td>UM</td>

                    <td align="center">
                        <html:select styleId="tipoActPerMod" property="tipoActPerMod"  >
                            <html:option value="-1">[--Seleccionar--]</html:option>
                            <html:option value="1">N°</html:option>
                            <html:option value="2">%</html:option>
                        </html:select>
                    </td>
                </tr>
                <tr id="btnnuevo">
                    <td colspan="2" align="center"><input type="button" value="Grabar" onclick="grabarnuevo()"/></td>
                </tr>
                <tr id="btncancelar">
                    <td colspan="2" align="center"><input type="button" value="Cancelar" onclick="cancelar()"/></td>
                </tr>
            </table>
            <br>
            <table id="detalle" border="0" align="center" cellspacing="0" style="width: 600px">
                <tr>
                    <td style="width: 150px">Descripci&oacute;n :</td>
                    <td style="width: 400px">
                        <html:text property="umActPer"  styleId="umActPer"/>
                    </td>
                </tr>
                <tr>
                    <td style="width: 150px">Cantidad</td>
                    <td style="width: 400px">
                        <html:text property="cantActPer"   styleId="cantActPer" styleClass="text"/>
                    </td>
                </tr>
                <td style="width: 150px"> UM :</td>
                <td style="width: 400px">
                    <html:select styleId="tipoActPer" property="tipoActPer" styleClass="select">
                        <html:option value="-1">[--Seleccionar--]</html:option>
                        <html:option value="1">N°</html:option>
                        <html:option value="2">%</html:option>
                    </html:select>
                </td>
                <tr>
                    <td style="width: 150px">
                        Presupuesto
                    </td>
                    <td style="width: 400px">
                        <html:text property="presupActPer"  styleId="presupActPer" styleClass="text" onkeypress="return isDecimalKey(event);"/>
                        <br>
                    <label style="color: red ">El monto no debe de pasar de 10 digitos enteros y  2 decimales.</label>
                    </td>
                </tr>
                <tr id="btneditar">
                    <td colspan="2" align="center"><input type="button" value="Grabar" onclick="grabar()"/></td>
                </tr>

            </table>
            <div id="divTabla">
            </div>
            <br><br>
        </html:form>
            </div>
    </body>
</html>